package cn.edu.csust.coursecard.controller;


import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

public class BaseController {
    
    protected final Integer getUserIdFromRequest(HttpServletRequest request){
        Integer userId = (Integer) request.getAttribute("userId");
        if(Objects.isNull(userId)){
            return null;
        }
        return userId;
    }
    
    protected final Boolean  getAdminFromRequest(HttpServletRequest request){
           return ((Boolean) request.getAttribute("admin"));
    }
    
}
